//
//  PrivacyController.m
//  WaywardPoint_Code
//
//  Created by 韩盼盼 on 15/8/20.
//  Copyright (c) 2015年 易网新科技. All rights reserved.
//

#import "PrivacyController.h"
@interface PrivacyController ()<UIWebViewDelegate,HeadBackView>
{
    UIButton *goBackBtn;
    UIWebView *protocol;
}
@end

@implementation PrivacyController

- (void)viewDidLoad {
    [super viewDidLoad];

    HeadBackView *headview=[HeadBackView headbackView:@"用户隐私协议" andrightBtn:nil];
    headview.delegate=self;
    [self.view addSubview:headview];
    
    [self showUI];

}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self test];
}
- (void)showUI {
    UIView *web=[[UIView alloc]initWithFrame:CGRectMake(0, 65, ScreenW, ScreenH-65)];
    [self.view addSubview:web];
    protocol=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, web.height)];
    protocol.delegate=self;
    protocol.dataDetectorTypes = UIDataDetectorTypeLink;
    [web addSubview:protocol];
}

- (void)test
{
    [MBProgressHUD showMessage:@"拼命加载中..."];    //自定义队列
    dispatch_queue_t queue2 = dispatch_queue_create("myQueue", NULL);
    dispatch_async(queue2, ^{
        NSString *urlstr = @"http://www.mrbang.com.cn/service.php";
        NSURLRequest *itcast=[NSURLRequest requestWithURL:[NSURL URLWithString:urlstr] ];
        [protocol loadRequest:itcast];
        //代码段1 费时间的操作:比如下载、复杂的计算
        dispatch_async(dispatch_get_main_queue(),
                       ^{
                           [MBProgressHUD hideHUD];
                           //加载请求
                           //代码2 回到主线程做的操作 比如更新UI界面
                       });
    });
    
}

- (void)btnback
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
